import 'package:favor_cate/core/route/route.dart';
import 'package:favor_cate/core/services/share.dart';
import 'package:favor_cate/core/viewmodel/favor_meal_veiw_model.dart';
import 'package:favor_cate/core/viewmodel/filter_view_model.dart';
import 'package:favor_cate/core/viewmodel/meal_view_model.dart';
import 'package:favor_cate/ui/shared/app_theme.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

void main() {
  runApp(MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (ctx) => FilterViewModel()),
        ChangeNotifierProxyProvider<FilterViewModel, MealViewModel>(
            create: (ctx) => MealViewModel(),
            update: (ctx, filterVM, mealVM) {
              mealVM!.update(filterVM);
              return mealVM;
            }),
        ChangeNotifierProvider(create: (ctx) => FavorMealViewModel())
      ],
      child: MyApp()));
}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    SizeFit.initSize();
    return MaterialApp(
      title: '美食广场',
      theme:AppTheme.normalTheme,
      initialRoute: MyRouter.initRoute,
      routes: MyRouter.routes,
      onUnknownRoute: MyRouter.unknownRoute,
      onGenerateRoute: MyRouter.generateRoute,
    );
  }
}

